package com.zyz.demo.mapper;

import com.zyz.demo.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("select id,`password` from user where `user_name` = #{userName} and delete_flag = 0")
    UserInfo selectUserPasswordByName(String name);

    @Select("select id,`user_name`,github_url,update_time from user where id = #{id} and delete_flag = 0")
    UserInfo selectUserInfoByUserId(Integer id);

    @Select("select count(*) from blog where user_id = #{userId} and delete_flag = 0")
    int getUserBlogSize(Integer userId);

    @Insert("insert into user (user_name,password,github_url,email) values (#{userName},#{password},#{githubUrl},#{email})")
    int addUserInfo(UserInfo userInfo);

    @Select("select count(*) from user where user_name = #{userName} and delete_flag = 0")
    int checkIndexExist(String userName);
}
